package ar.com.jsejtman.common.security.schema.service;

import ar.com.jsejtman.common.persistence.exception.DaoException;
import ar.com.jsejtman.common.security.schema.dao.AuthoritiesGroupDao;
import ar.com.jsejtman.common.security.schema.entity.AuthoritiesGroup;
import ar.com.jsejtman.common.service.definition.BaseService;
import ar.com.jsejtman.common.service.exception.EntitySavingException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * Permite manipular grupos de autoridades.
 * 
 * @author jsejtman
 */
@Service
@Transactional
public class AuthoritiesGroupService extends BaseService implements IAuthoritiesGroupService {

	@Override
	public final Long saveAuthoritiesGroup(final AuthoritiesGroup authoritiesGroup)
	        throws EntitySavingException {

		try {
			final AuthoritiesGroupDao dao = this.getDaoFactory().newDao(AuthoritiesGroupDao.class);

			return (dao.save(authoritiesGroup));

		} catch (final DaoException e) {
			throw new EntitySavingException(e.getMessage(), e);
		}
	}
}
